package 力扣._84_柱状图中的最大矩形;

import java.util.Deque;
import java.util.LinkedList;

class Solution {
    public int largestRectangleArea(int[] heights) {


        int max_s = Integer.MIN_VALUE;  // 最大面积

        for (int i = 0; i < heights.length; i++) {
            int min = Integer.MAX_VALUE;    // 当前占中最小值
            for (int j = i; j < heights.length; j++) {
                min = Math.min(min, heights[j]);
                max_s = Math.max(max_s, min * (j - i + 1));
                if(max_s>= (heights.length - i) * min)
                    break;
            }
        }
        return max_s;


    }
}